﻿@{
    Layout = "_Layout";
}
<div id="app">
    <el-row>
        <el-col :span="24">
            <div class="grid-content bg-purple-dark">
                <el-input v-model="filterEvalName" placeholder="请输入测评名称" style="width:300px;" clearable></el-input>
                <el-button type="primary" v-on:click="loadTableData" style="margin-left:10px;width:98px;">搜索</el-button>
                <el-button type="primary" v-on:click="addEval">添加测评</el-button>
            </div>
        </el-col>
    </el-row>
    <hr class="line-gray" />
    <el-row>
        <div class="table-container">
            <el-table :data="tableData" style="width:100%">
                <el-table-column type="index" width="50" label="编号">

                </el-table-column>
                <el-table-column label="测试名称" width="120" property="name">

                </el-table-column>
                <el-table-column label="所属机构" width="150" property="instructionName">

                </el-table-column>
                <el-table-column label="状态" width="120" property="status">
                    <template slot-scope="scope">
                        <span v-if="scope.row.status===0" style="color:#67C23A">创建</span>
                        <span v-else-if="scope.row.status===1" style="color:#409EFF">使用中</span>
                        <span v-else style="color:#909399">禁用</span>
                    </template>
                </el-table-column>
                <el-table-column label="费用" width="120" property="isFree">
                    <template slot-scope="scope">
                        <span v-if="scope.row.isFree" style="color:#E6A23C">收费</span>
                        <span v-else style="color:#67C23A">免费</span>
                    </template>
                </el-table-column>
                <el-table-column label="原价" width="100" property="normalPrice">
                    <template slot-scope="scope">
                        <span>{{scope.row.normalPrice}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="白银会员" width="100" property="normalPrice">
                    <template slot-scope="scope">
                        <span>{{scope.row.normalPrice}}{{scope.row.normalPrice?'￥':''}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="黄金会员" width="100" property="normalPrice">
                    <template slot-scope="scope">
                        <span>{{scope.row.normalPrice}}{{scope.row.normalPrice?'￥':''}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="钻石会员" width="100" property="normalPrice">
                    <template slot-scope="scope">
                        <span>{{scope.row.diamondPrice}}{{scope.row.normalPrice?'￥':''}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="时长" width="100" property="lastTime">
                    <template slot-scope="scope">
                        <span>{{scope.row.lastTime}}{{scope.row.lastTime?'分钟':''}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="活动" width="100" property="isActive">
                    <template slot-scope="scope">
                        <span>{{scope.row.lastTime}}{{scope.row.lastTime?'分钟':''}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button size="mini" v-on:click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                        <el-button size="mini" type="danger" v-on:click="deleteEval(scope.$index, scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </el-row>
</div>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            userType: '',  // 用户类型
            insId: '',
            filterEvalName: '',
            tableData: [],
            formLabelWidth: '70px',
        },
        methods: {
            deleteEval(index, row) {
                var that = this;
                that.$confirm('测评将被删除, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get(`/api/evaluation/delete-evalution?Id=${row.id}`)
                        .then((res) => {
                            if (res.data.code === 0) {
                                that.$message({
                                    message: res.data.msg,
                                    type: 'success'
                                });
                                that.addDialogVisible = false;
                                that.loadTableData();
                            }
                        });
                });
            },
            // 加载表格数据
            loadTableData() {
                let that = this;
                axios.get(`/api/evaluation/get-ins-evaluation-list?filterName=${that.filterEvalName}`)
                    .then((res) => {
                        that.tableData = res.data.data;
                    });
            },
            handleEdit(index, row) {
                window.location.href = `/evaluation/add?actionType=edit&id=${row.id}`
            },
            addEval(index,row) {
                window.location.href=`/evaluation/add?actionType=add`
            }
        },
        created() {
            let that = this;
            that.userType = @ViewBag.UserType;
            if (that.userType === 1) {
                    that.insId = @ViewBag.InsId
            }
            that.loadTableData();
        },
        mounted() {

        }
    });
</script>
<style>

</style>